package org.jeecg.modules.LdProjectInfo.util;

import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Component;

@Log4j2
@Component
public class QxWxPush {


    /**
     * 企业微信消息推送内部应用接口URL,部署服务器无外网,中转一次
     */
    private final static String MESSAGE_PUSH_URL = "http://10.0.0.140:12880/landai/sys/thirdApp/pushWechatEnterpriseMessage";

    private void pushMessage(String title, String content, String toUser, String url) {
        try {
            // 消息推送
                WechatEnterpriseMessageVo vo = new WechatEnterpriseMessageVo();
                vo.setTitle(title);
                vo.setContent(content);
                vo.setToUser(toUser);
                vo.setUrl(url);
                vo.setSecret("3a57a50640ba40f7a9e94b455ce4e764");

                String res = HttpUtil.post(MESSAGE_PUSH_URL, JSONObject.toJSONString(vo), 2000);
                log.info("企业微信消息推送接口响应:{}", res);
        } catch (Exception e) {
            log.info("企业微信消息推送接口异常:{}", e.getMessage());
        }
    }
}
